package com.xianyu.ssoserver.registry;

import com.menghao.sso.server.model.ticket.Ticket;

/**
 * 基于最大使用次数
 */
public final class MultiTimeUseExpirationPolicy implements
        ExpirationPolicy {

    private final int numberOfUses;

    public MultiTimeUseExpirationPolicy(final int numberOfUses) {
        this.numberOfUses = numberOfUses;
    }

    public boolean isExpired(final Ticket ticket) {
        return (ticket == null) || (ticket.getCountOfUses() >= this.numberOfUses);
    }
}
